<?php
class Analytics_model extends Model
{
    private $table = 'analytics';
    public function getList($from, $to) {
        if(!$from || !$to) return false;
        $sql = 'SELECT `visit`,`pageview`,`create`
                FROM '. $this->table .' 
                WHERE FROM_UNIXTIME(`create`, \'%Y-%m-%d\') BETWEEN "'. $from .'" AND "'. $to .'"
                ORDER BY `create` ASC';
        $result = $this->db->query($sql);  //print_r($result->result_object()); die;
        return $result->result_object();
    }
    
    public function add($sql) {
        if(!$sql) return false;
        $result = $this->db->query('INSERT INTO '. $this->table .' (`visit`, `pageview` ,`create`) VALUES ' . implode(',', $sql));
        return $result;
    }
}
?>
